package com.app.aipass.view;//package com.app.csc.view;
//
//import android.content.Context;
//import android.graphics.drawable.AnimationDrawable;
//import android.util.AttributeSet;
//import android.view.View;
//import android.widget.FrameLayout;
//import android.widget.ImageView;
//import android.widget.TextView;
//
//import androidx.annotation.ColorInt;
//import androidx.annotation.DrawableRes;
//import androidx.swiperefreshlayout.widget.CircularProgressDrawable;
//
//import com.app.csc.R;
//import com.lcodecore.tkrefreshlayout.IHeaderView;
//import com.lcodecore.tkrefreshlayout.OnAnimEndListener;
//
//public class MySinaRefreshView extends FrameLayout implements IHeaderView {
//
//    private ImageView refreshArrow;
//    private ImageView loadingView;
//    private TextView refreshTextView;
//
//    public MySinaRefreshView(Context context) {
//        this(context, null);
//    }
//
//    public MySinaRefreshView(Context context, AttributeSet attrs) {
//        this(context, attrs, 0);
//    }
//
//    public MySinaRefreshView(Context context, AttributeSet attrs, int defStyleAttr) {
//        super(context, attrs, defStyleAttr);
//        init();
//    }
//    private static final int MAX_ALPHA = 255;
//    CircularProgressDrawable mProgress;
//    private void init() {
//        View rootView = View.inflate(getContext(), R.layout.view_sinaheader, null);
//        refreshArrow = (ImageView) rootView.findViewById(R.id.iv_arrow);
//        refreshTextView = (TextView) rootView.findViewById(R.id.tv);
//        loadingView = (ImageView) rootView.findViewById(R.id.iv_loading);
//        refreshTextView.setVisibility(View.GONE);
//        refreshArrow.setVisibility(View.GONE);
//        mProgress = new CircularProgressDrawable(getContext());
//        mProgress.setStyle(CircularProgressDrawable.DEFAULT);
//        loadingView.setImageDrawable(mProgress);
//        addView(rootView);
//    }
//
//    public void setArrowResource(@DrawableRes int resId) {
//        refreshArrow.setImageResource(resId);
//    }
//
//    public void setTextColor(@ColorInt int color) {
//        refreshTextView.setTextColor(color);
//    }
//
//    public void setPullDownStr(String pullDownStr1) {
//        pullDownStr = pullDownStr1;
//    }
//
//    public void setReleaseRefreshStr(String releaseRefreshStr1) {
//        releaseRefreshStr = releaseRefreshStr1;
//    }
//
//    public void setRefreshingStr(String refreshingStr1) {
//        refreshingStr = refreshingStr1;
//    }
//
//    private String pullDownStr = "下拉刷新";
//    private String releaseRefreshStr = "释放刷新";
//    private String refreshingStr = "正在刷新";
//
//    @Override
//    public View getView() {
//        return this;
//    }
//
//    @Override
//    public void onPullingDown(float fraction, float maxHeadHeight, float headHeight) {
//        if (fraction < 1f) refreshTextView.setText(pullDownStr);
//        if (fraction > 1f) refreshTextView.setText(releaseRefreshStr);
//        refreshArrow.setRotation(fraction * headHeight / maxHeadHeight * 180);
//    }
//
//    @Override
//    public void onPullReleasing(float fraction, float maxHeadHeight, float headHeight) {
//        if (fraction < 1f) {
//            refreshTextView.setText(pullDownStr);
//            refreshArrow.setRotation(fraction * headHeight / maxHeadHeight * 180);
//            if (refreshArrow.getVisibility() == GONE) {
////                refreshArrow.setVisibility(VISIBLE);
//                loadingView.setVisibility(GONE);
//            }
//        }
//    }
//
//    @Override
//    public void startAnim(float maxHeadHeight, float headHeight) {
//        refreshTextView.setText(refreshingStr);
//        refreshArrow.setVisibility(GONE);
//        loadingView.setVisibility(VISIBLE);
////        ((AnimationDrawable) loadingView.getDrawable()).start();
//
//        mProgress.setAlpha(MAX_ALPHA);
//        mProgress.start();
//    }
//
//    @Override
//    public void onFinish(OnAnimEndListener listener) {
//        listener.onAnimEnd();
//    }
//
//    @Override
//    public void reset() {
////        refreshArrow.setVisibility(VISIBLE);
//        mProgress.stop();
//        loadingView.setVisibility(GONE);
//        refreshTextView.setText(pullDownStr);
//    }
//}
//
